script(src="/rating.js")
h2= title
#posts
  - if (posts.length === undefined) posts = [posts]
  - each post in posts
    div(class="post", id=post._id)
      div.title
        a(href="/posts/"+post._id)!= post.title
      div.body= post.body
      div.tags
        - each tag in post.tags
          a.tag(href="/tags/"+tag.tag) #
            =tag.tag 
      div.created= post.created
      div(class="votes", id=post._id+"_votes") Rating: 
        =post.likes.length - post.dislikes.length
      div.actions
      - if (user)
        button(onclick="rate(\""+post._id+"\",\"like\")") like
        button(onclick="rate(\""+post._id+"\",\"dislike\")") dislike
      - if (!post.reply_to)
        a(href="/topics/"+post._id) show all topic
        - if (user)
          a(href="/topics/"+post._id+"/reply") reply
      - else
        a(href="/topics/"+post.reply_to) show all topic
        - if (user)
          a(href="/topics/"+post.reply_to+"/reply") reply
